package websimulator;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Chart
 */
@WebServlet("/Chart")
public class Chart extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Chart() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		String answer = "$(function () {var chart;$(document).ready(function() {chart = new Highcharts.Chart({chart: {renderTo: 'container',type: 'area'},title: {text: 'Area chart with negative values'},xAxis: {categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']},tooltip: {formatter: function() {return ''+this.series.name +': '+ this.y +'';}},credits: {enabled: false},series: [{name: 'John',data: [5, 3, 4, 7, 2]}, {name: 'Jane',data: [2, -2, -3, 2, 1]}, {name: 'Joe',data: [3, 4, 4, -2, 5]}]});});});</script></div>";
		
		response.setContentType("text/plain");
		response.getWriter().write(answer);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

}
